<template>
  <div>
    <div class="addbut"></div>

    <div id="queryDiv">
      <el-input class="queryInput" v-model="queryForm.sellerName" placeholder="车主"></el-input>
      <el-input class="queryInput" v-model="queryForm.sellerMobile" placeholder="车主电话"></el-input>
      <el-select v-model="queryForm.status" placeholder="请选择审核状态" >
        <el-option  label="全部" value="-1"></el-option>
        <el-option  label="待审核" value="0"></el-option>
        <el-option  label="通过" value="1"></el-option>
        <el-option  label="不通过" value="2"></el-option>
      </el-select>
      <el-button @click="loadGrid()" type="primary" class="search">搜索</el-button>
    </div>
    <div v-loading="loading.table">
      <el-table :data="truckList"  style="width: 100%;font-size:12px" border highlight-current-row>


        <el-table-column prop="userName" label="客户名称" align="center"></el-table-column>
        <el-table-column prop="userMobile" label="客户手机号" align="center"></el-table-column>

        <el-table-column prop="sellerName" label="车主" align="center"></el-table-column>
        <el-table-column prop="sellerMobile" label="车主电话" align="center"></el-table-column>
        <el-table-column prop="typeName" label="车型" align="center"></el-table-column>
        <el-table-column prop="brandName" label="品牌名称" align="center"></el-table-column>
        <el-table-column prop="color" label="颜色" align="center"></el-table-column>

        <el-table-column prop="sellPrice" label="价格" align="center"></el-table-column>
        <el-table-column prop="address" label="看车地址" align="center"></el-table-column>

        <el-table-column prop="outStandardStr" label="排放标准" align="center"></el-table-column>
        <el-table-column prop="enginePower" label="最大马力" align="center"></el-table-column>
        <el-table-column prop="boxLength" label="箱体长度" align="center"></el-table-column>
        <el-table-column prop="mileage" label="里程(万公里)" align="center"></el-table-column>

        <el-table-column label="审核状态" align="center">
          <template slot-scope="scope">
            <el-tag :type="scope.row.status==1?'success':'warning'"   disable-transitions style="margin-right: 10px;margin-top: 5px">
              {{scope.row.statusStr}}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column  label="操作" min-width="250" align="center">
          <template slot-scope="scope">
            <i class="el-icon-star-on el-icon--right"></i>
            <el-button type="text" @click="toEdit(scope.row,'audit')">审核</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination @current-change="paginationChangeFn" background layout="prev, pager, next" :page-count="pagination.pageCount"> </el-pagination>
    </div>

    <el-dialog title="审核结果" :visible.sync="auditDialog"  >
        <el-row>
          <el-col :span="8">
              <el-radio v-model="form.status" :label="1" border class="truckTypes">通过</el-radio>
              <el-radio v-model="form.status" :label="2" border class="truckTypes">不通过</el-radio>
         </el-col>
        </el-row>

        <el-row>
          <el-col :offset="8">
             <el-button type="primary" @click="saveAudit()">保存</el-button>
             <el-button type="warning" @click="auditDialog=false">关闭</el-button>
          </el-col>
        </el-row>

    </el-dialog>

    <el-dialog title="是否上架" :visible.sync="shelfDialog"  >

      <el-row>
        <el-col :span="8">
          <el-radio v-model="form.onShelf" :label="1" border class="truckTypes">上架</el-radio>
          <el-radio v-model="form.onShelf" :label="0" border class="truckTypes">下架</el-radio>
        </el-col>
      </el-row>

      <el-row>
        <el-col :offset="8">
          <el-button type="primary" @click="saveShelf()">保存</el-button>
          <el-button type="danger" @click="shelfDialog=false">关闭</el-button>
        </el-col>
      </el-row>

    </el-dialog>


  </div>
</template>

<script>
    export default {
        name:'AuditList',
        data() {
            return {
                truckId:0,
                auditDialog:false,
                shelfDialog:false,
                truckList:[],
                queryForm:{
                    sellerMobile:'',
                    sellerName:'',
                    userId:0,
                    status:'0'
                },
                form:{
                    status:0,
                    onShelf:''
                },
                loading: {table: false},
                pagination: {currentPage: 1, pageCount: 0 }//总页数
            };
        },
        methods: {
            paginationChangeFn(currentPage) {
                this.pagination.currentPage = currentPage;
                this.loadGrid();
            },
            loadGrid() {
                this.loading.table=true;
                let params = this.queryForm;
                params.currentPage = this.pagination.currentPage;
                this.$api.listAudit(params).then(response=>{
                    let result = response.data;
                    let data = result.data;
                    if(result.code==0){
                        this.truckList = data.list;
                    }
                    this.loading.table=false;
                    this.pagination.pageCount = result.data.totalPage;
                });
            },
            toEdit(row,operateType){
                let params = {'truckId':row.truckId,operateType:operateType};
                this.$router.push({name:'Audit',params:params});
            }
        },
        created() {
            //看是否是从用户列表中跳转的
            let params = this.$route.params;
            if(params&&params.userId){
              this.queryForm.userId = params.userId;
            }
            this.loadGrid();
        },
        mounted(){
        }
    };
</script>

<style lang="less" scoped>
  .addbut{
    margin-bottom:20px;
  }
  #statusSwitch {
    display: block;
  }
  .el-icon--right{
    color:#4db3ff;
    margin-left:15px
  }
  #queryDiv {
    margin-bottom: 20px;
    .queryInput {
      width:200px;
      margin-right:20px
    }
    .search{
      margin-left:20px
    }
    .btn-add{
      margin-left: 150px;
    }
  }
  .imgsrc{
    margin-left:20px;
    margin-top:10px;
  }
  .el-table .cell {
    white-space: pre-line;
  }

</style>
